/**
 * @author Cator Vee  hi@catorv.com
 */
import { forEach, isString, isNumber, isObject } from '../utils'

export default function classnames () {
  let classes = []

  Array.from(arguments).forEach(arg => {
    if (!arg) {
      return
    }
    if (isString(arg) || isNumber(arg)) {
      classes.push(arg)
    } else if (Array.isArray(arg) && arg.length) {
      const inner = classnames.apply(null, arg)
      if (inner) {
        classes.push(inner)
      }
    } else if (isObject(arg)) {
      forEach(arg, (value, key) => {
        if (value) {
          classes.push(key)
        }
      })
    }
  })

  return classes.join(' ')
}
